winbrew_cli\services\startup/
config.rs

1//! Configuration capture for CLI startup.
2//!
3//! This submodule converts the persisted storage configuration into the
4//! runtime command context. It does not start any process services; that work
5//! belongs in [`super::process`]. The split keeps startup easy to reason about:
6//! config loading answers "what should this process do?" while process
7//! initialization answers "what global state does it need to do it?".
8
9use anyhow::Result;
10
11use crate::{CommandContext, database};
12
13/// Load the current persisted configuration snapshot used by CLI startup.
14///
15/// This reads the active storage-backed configuration, including any path
16/// overrides that are already part of the environment-controlled config model.
17pub(super) fn load() -> Result<database::Config> {
18    database::Config::load_current()
19}
20
21/// Build the command context that will be used for the rest of the process.
22///
23/// The returned [`CommandContext`] combines application runtime state with UI
24/// preferences from the loaded config. The `verbosity` value only affects the
25/// runtime application context; it does not rewrite the persisted config.
26pub(super) fn build_context(config: &database::Config, verbosity: u8) -> Result<CommandContext> {
27    CommandContext::from_config_with_verbosity(config, verbosity)
28}